using Ln.Fram.SqlSugarCore.Abstractions;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;

namespace Ln.Fram.Ddd.Application;

public abstract class CrudService<TEntity, TEntityDto, TKey>(
	ISqlSugarRepository<TEntity, TKey> repository)
	: CrudService<TEntity, TEntityDto, TKey, PagedAndSortedResultRequestDto>(repository)
	where TEntity : class, IEntity<TKey>, new()
{
}

public abstract class CrudService<TEntity, TEntityDto, TKey, TGetListInput>(
	ISqlSugarRepository<TEntity, TKey> repository)
	: CrudService<TEntity, TEntityDto, TKey, TGetListInput, TEntityDto>(repository)
	where TEntity : class, IEntity<TKey>, new()
{
}
	

public abstract class CrudService<TEntity, TOutputDto, TKey, TGetListInput, TCreateUpdateInput>(
	ISqlSugarRepository<TEntity, TKey> repository)
	: CrudService<TEntity, TOutputDto, TKey, TGetListInput, TCreateUpdateInput, TCreateUpdateInput>(repository)
	where TEntity : class, IEntity<TKey>, new()
{
}

public abstract class CrudService<TEntity, TOutputDto, TKey, TGetListInput, TCreateInput, TUpdateInput>(
	ISqlSugarRepository<TEntity, TKey> repository)
	: CrudService<TEntity, TOutputDto, TOutputDto, TKey, TGetListInput, TCreateInput, TUpdateInput>(repository)
	where TEntity : class, IEntity<TKey>, new()
{
}

public abstract class CrudService<TEntity, TGetOutputDto, TGetListOutputDto, TKey, TGetListInput, TCreateInput,
	TUpdateInput>(ISqlSugarRepository<TEntity, TKey> repository)
	: AbstractCrudService<TEntity, TGetOutputDto, TGetListOutputDto, TKey, TGetListInput, TCreateInput, TUpdateInput>(
		repository)
	where TEntity : class, IEntity<TKey>, new()
{
	#region 成员属性
	private new ISqlSugarRepository<TEntity, TKey> Repository { get; } = repository;
	#endregion

	#region 重写方法
	protected override async Task DeleteDoneAsync(TKey id)
	{
		await Repository.DeleteAsync(id);
	}

	protected override async Task<TEntity> GetEntityByIdAsync(TKey id)
	{
		return await Repository.GetAsync(id);
	}
	#endregion
}